﻿using ApiManage.Models.zyhModels;
using ApiManage.Service.MsSql.IService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace ApiManage.Service.MsSql.Service
{
    public class SysRoleService : BaseService, ISysRoleService
    {

        public List<SysRole> GetRole(Expression<Func<SysRole, bool>> where) => _zyhContext.SysRole.Where(where).ToList();
        public void AddRole(SysRole param)
        {
            _zyhContext.SysRole.Add(param);
            _zyhContext.SaveChanges();
        }

        public void EditRole(SysRole param)
        {
            _zyhContext.SysRole.Update(param);
            _zyhContext.SaveChanges();
        }

        public void DelRole(int id)
        {
            var role = _zyhContext.SysRole.FirstOrDefault(o => o.RoleId == id);
            role.Mark = 9;
            _zyhContext.SaveChanges();
        }
    }
}
